/*
 * @(#)LogicOperatorClear.java    0.2 01/04/2009
 */
package com.ly.mpayment.persist.catstorage;

import java.util.regex.Pattern;

/**
 * 逻辑运算符清理器
 * <p>该清理器用于清理语句中作废的“and”、“or”关键字</p>
 * 
 * @version 0.2
 * @since 0.2
 */
public class LogicOperatorClear implements Clear {

    /**
     * 清理废逻辑运算符的正则表达式
     */
    private Pattern logicOperatorRegex = Pattern.compile("(where|having|\\()\\s+(\\band\\b|\\bor\\b)\\s+", Pattern.CASE_INSENSITIVE);

    public String clear(String statement) {
        return logicOperatorRegex.matcher(statement).replaceAll("$1 ");
    }
}
